"""调整子图周围的间距"""
import matplotlib.pyplot as plt
import numpy as np

fig, axes = plt.subplots(2, 2, sharex=True, sharey=True)
for i in range(2):
    for j in range(2):
        axes[i, j].hist(np.random.randn(500), bins=50, color='r', alpha=0.5)  # 利用numpy随机生成的数据绘制直方图
plt.subplots_adjust(wspace=0, hspace=0)
plt.show()
# 保存图片,transparent=True指定图片透明度,pad_inches=0去除所有白边
fig.savefig("pic/ex4.png", format='png', transparent=True, dpi=300, pad_inches=0)